package com.project.business.service;

import com.project.business.feign.OrderFeign;
import com.project.business.feign.StorageFeign;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @program: seata-at
 * @description: 商品交易
 * @author: mml
 * @create: 2023/12/20
 */
@Service
public class BussinessService {

    @Autowired
    private OrderFeign orderFeign;

    @Autowired
    private StorageFeign storageFeign;

    @GlobalTransactional
    public boolean purchase(String account, String projectId, Integer count) {
        storageFeign.deduct(projectId, count);
        orderFeign.createOrder(account, projectId, count);
        return true;
    }
}
